package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsGrouponRulesMapper;
import com.qf.pojo.DtsGrouponRules;
import com.qf.service.DtsGrouponRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class DtsGrouponRulesServiceImpl implements DtsGrouponRulesService {
    @Autowired
    DtsGrouponRulesMapper grouponRulesMapper;
    @Override
    public IPage<DtsGrouponRules> findByPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsGrouponRules> iPage = new Page<>(page,limit);
        QueryWrapper<DtsGrouponRules> qw = new QueryWrapper<>();
        if(!StringUtils.isEmpty(sort)&&!StringUtils.isEmpty(order)){
            if(order.equalsIgnoreCase("desc")){
                qw.orderByDesc(sort);
            }else{
                qw.orderByAsc(sort);
            }
        }
       grouponRulesMapper.selectPage(iPage,qw);


        return iPage;
    }
}
